package com.jinhongone.pattern.behavior.mediator;

/**
 * @author jinho
 * @className MediatorStructure
 * @description 具体中介者角色
 * @date 2025/4/16 16:59
 */
public class MediatorStructure extends Mediator {

    //中介知道全部的同事
    private HouseOwner houseOwner;
    private Tenant tenant;

    public HouseOwner getHouseOwner() {
        return houseOwner;
    }

    public void setHouseOwner(HouseOwner houseOwner) {
        this.houseOwner = houseOwner;
    }

    public Tenant getTenant() {
        return tenant;
    }

    public void setTenant(Tenant tenant) {
        this.tenant = tenant;
    }

    //中介提供的同事之间互相联系方式（同事之间交互逻辑）
    @Override
    public void contact(String msg, Person person) {
        if (person == houseOwner) {
            tenant.getMsg(person.name + "说：" + msg);
        } else {
            houseOwner.getMsg(person.name + "说：" + msg);
        }
    }
}
